package com.niiwoo.civet.mobile.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.niiwoo.civet.mobile.vo.request.analysis.UserDataAnalysisRequestVO;
import com.niiwoo.civet.snapdata.service.TianChengDataAnalysisDubboService;
import com.niiwoo.tripod.web.annotation.AuthIgnore;
import com.niiwoo.tripod.web.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @Description: 数据分析
 * @Author:Liujinping
 * @Date:2017/12/03
 */
@Slf4j
@RestController
@RequestMapping("/userDataAnalysis")
@Api(tags = "用户数据分析【刘金平】", description = "/userDataAnalysis")
public class UserDataAnalysisController {
    @Reference(version = "1.0.0")
    TianChengDataAnalysisDubboService analysisDubboService;

    @PostMapping("/userContactsAnalysis")
    @ApiOperation("通讯录分析")
    @AuthIgnore
    public Result<Boolean> contactsAnalysis(@RequestBody @Valid UserDataAnalysisRequestVO vo) {
        boolean flag = analysisDubboService.contactsAnalysis(vo.getUserId(),vo.getMobilePhone(),vo.getFromSource());
        return Result.with(flag);
    }

    @PostMapping("/userCallRecordAnalysis")
    @ApiOperation("通话记录分析")
    @AuthIgnore
    public Result<Boolean> callRecordAnalysis(@RequestBody @Valid UserDataAnalysisRequestVO vo) {
        boolean flag = analysisDubboService.callRecordAnalysis(vo.getUserId(),vo.getMobilePhone(),vo.getFromSource());
        return Result.with(flag);
    }

    @PostMapping("/userSmsAnalysis")
    @ApiOperation("短信分析")
    @AuthIgnore
    public Result<Boolean> smsAnalysis(@RequestBody @Valid UserDataAnalysisRequestVO vo) {
        boolean flag = analysisDubboService.smsAnalysis(vo.getUserId(),vo.getMobilePhone());
        return Result.with(flag);
    }
}
